package com.explorex.infra.puma.gateway.netty.common;

import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;

import java.util.Map;

/**
 * @author: JacceYang
 * @createTime: 2022/07/19 9:01 下午
 * @description: Session 应该具备的基础能力描述
 */
public interface BaseSocketSession extends BaseSessionAttribute {

    /**
     * sendBinaryMessage
     *
     * @param msg
     * @return
     */
    ChannelFuture sendMessage(Object msg);


    /**
     * service kickout client socket
     *
     * @param msg
     * @return
     */
    ChannelFuture closeSocket(String msg);

    Channel channel();

    Map<String, String> getExtra();

    /**
     * bind的用户
     * @return
     */
    Map<String, UserKey> getTokenUserInfo();

    /**
     * auth的用户
     * @return
     */
    UserKey getAuthUser();

    /**
     * 当前socket 使用的通讯协议
     *
     * @return
     */
    ProtocolEnum protocol();

    /**
     * 通道是否可写
     */
    boolean canWrite();

    int nextSeqId();

    AuthStatusEnum getAuth();

    long getLastTime();

    void setLastTime(long time);

    void setStatus(int status);

    void setAuth(AuthStatusEnum auth);

    boolean isAckRetryFuse();

    /**
     *
     * @param ackRetryFuse
     * @return
     */
     void setAckRetryFuse(boolean ackRetryFuse) ;


     boolean isRateLimited();

     void refresh(boolean force);

}
